﻿using System;

class FallDown
{
    static void Main()
    {
        int matrixSize = 8;
        int[,] matrix = new int[matrixSize, matrixSize];

        //read and store in matrix
        for (int row = 0; row < matrixSize; row++)
        {
            int number = int.Parse(Console.ReadLine());
            for (int col = 0; col < matrixSize; col++)
            {
                matrix[row, col] = ((number >> col) & 1);
            }
        }

        int[,] newMatrix = new int[matrixSize, matrixSize];

        //fall down
        for (int col = matrixSize - 1; col >= 0; col--)
        {
            int countFullCell = 0;
            for (int row = 0; row < matrixSize; row++)
            {
                if (matrix[row, col] == 1)
                {
                    countFullCell++;
                }
            }
            int newRow = matrixSize - 1;
            while (countFullCell > 0)
            {
                newMatrix[newRow, col] = 1;
                countFullCell--;
                newRow--;
            }
        }

        //print decimal from binary in matrix
        for (int row = 0; row < matrixSize; row++)
        {
            int number = 0;
            for (int col = matrixSize - 1; col >= 0; col--)
            {
                number += (int)Math.Pow(2, col) * newMatrix[row, col];
            }
            Console.WriteLine(number);
        }
    }
}